/*
 * Energia_Potencial_HMF.h
 *
 *  Created on: 03/09/2013
 *      Author: steiner
 */

#ifndef ENERGIA_POTENCIAL_HMF_H_
#define ENERGIA_POTENCIAL_HMF_H_

void EnergiaPotencial_HMF(long, double*, double*, double*, double*);

#endif /* ENERGIA_POTENCIAL_HMF_H_ */

#include <stdlib.h>
#include <stdio.h>

void EnergiaPotencial_HMF(long n, double *magx, double *magy, double *ptot, double *mass){

	int i, j;
	double aux1, aux2;


	for(i = 0 ; i < n - 1 ; i++ ){
		for( j = i + 1 ; j < n ; j++ ){
			aux2 = mass[i]*mass[j];
			aux1 += aux2*(1.0-*magx*(*magx)-*magy*(*magy))/2.0;
			//	printf("%lf\n ", aux2);
		}
	}

	*ptot = aux1/((double) n*n);
	return;
}
